package innerclass;

/**
 * Created by Terry
 * Description:
 * User: GAOBO
 * Date: 2021-07-27
 * Time: 10:40
 */

/*class OuterClass {
    public int data1 = 1;
    private int data2 = 2;
    public static int data3 = 3;

    public void func() {
        System.out.println("OuterClass::func()");
    }

    *//**
     * 实例内部类:
     * 可以把实例内部类  当做就是一个实例成员
     *//*
    class InnerClass {
        public int data1 = 1000;
        public int data4 = 4;
        private int data5 = 5;
        //public static int data6 = 6; //
        public static final int data6 = 6;

        public void funcInner() {
            System.out.println("InnerClass::funcInner");
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(OuterClass.this.data1);
        }
    }
}*/

/*class OuterClass {
    public int data1 = 1;
    public int data2 = 2;
    public static int data3 = 3;

    public void func() {
        System.out.println("OuterClass::func()");
    }

    */

import java.util.Comparator;
import java.util.PriorityQueue;

/**
     * 静态内部类:
     * 可以把静态内部类     当做就是一个静态成员
     *//*
    static class InnerClass {
        public int data1 = 1000;
        public int data4 = 4;
        private int data5 = 5;
        public static int data6 = 6; //
        public OuterClass out;
        public InnerClass(OuterClass o) {
            this.out = o;
        }

        public void funcInner() {
            System.out.println(data1);
            System.out.println(this.out.data2);
        }
    }
}*/
class OuterClass {
    public void func() {
        System.out.println("OuterClass::func()");
    }
}
class AgeCompartor {

}
public class TestDemo {

    interface A {
        public void func();
    }

    A a = new A(){
        @Override
        public void func() {
            System.out.println("当前是个匿名内部类，实现了A接口，重写了接口的方法");
        }
    };





    public static void main(String[] args) {

        PriorityQueue<Integer> priorityQueue = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return 0;
            }
        });


        int local = 199;

        //匿名子类
        new OuterClass(){
            @Override
            public void func() {
                //local = 777;
                System.out.println("我是重写的func()");
                System.out.println(local);
            }
        }.func();
    }

   /* public static void main(String[] args) {
        OuterClass outerClass = new OuterClass();

        OuterClass.InnerClass innerClass = new OuterClass.InnerClass(outerClass);
        innerClass.funcInner();

    }*/

    /*public static void main(String[] args) {
        OuterClass.InnerClass innerClass2 = new OuterClass().new InnerClass();
        innerClass2.funcInner();
    }

    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
    }*/
}
